<template>
	<view class="login-view">
		<image src="../../static/logo.png" mode="widthFix"></image>
		<text class="app-name">雨果体育</text>
		<view class="from-view">
			<u--input border="none" class="input-view" prefixIcon="account-fill" placeholder="账号"
				v-model="fromData.username"></u--input>
			<u--input border="none" class="input-view" type="password" prefixIcon="lock-fill" placeholder="密码"
				v-model="fromData.password"></u--input>
			<view class="submit-view">
				<u-button :disabled="fromData.username === '' || fromData.password === ''" type="primary" text="登录"
					@click="submit"></u-button>
			</view>
		</view>
	</view>
</template>

<script>
import { login } from '@/common/api/home'
export default {
	data () {
		return {
			fromData: {
				username: '',
				password: '',
				rememberMe: false
			}
		}
	},
	methods: {
		submit () {
			login(this.fromData).then(res => {
				console.log(res)
				uni.setStorageSync('token', res.msg);
				this.$Router.replace('/')
			}).catch(err => {
				uni.showToast({
					title: err.msg,
					icon: 'none',
					duration: 1500
				});
			})
		}
	}
}
</script>

<style lang="less">
.app-name {
	font-size: 30rpx;
	font-weight: bold;
	position: relative;
	margin-top: -80rpx;
}

.login-view {
	display: flex;
	flex-direction: column;
	align-items: center;
	height: 100vh;
	padding: 0 40rpx;
	background-color: #fff;

	.from-view {
		width: 100%;
		margin-top: 80rpx;

		.input-view {
			padding: 20rpx !important;
			margin-bottom: 30rpx;

			background-color: #f9f9f9;
		}

		.submit-view {
			margin-top: 60rpx;
		}
	}
}
</style>
